home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8412.arc / TAD.ASM < prev    next >
Assembly Source File  |  1986-09-14  |  3KB  |  81 lines

  1.   page        55,132
  2.   title        TAD:  Time and Date Program for PC/AT
  3. ; Author:    Will Fastie        on 84/10/01 10:05
  4. ; Environment:    IBM PC/AT, DOS 3.00 or higher
  5. ; DOS Syntax:    TAD
  6. ;
  7. ; This program provides a DOS command to set the DOS date and time
  8. ; into the BIOS real-time-clock; the BIOS routine also sets CMOS.
  9. ; On other PC family members and in DOS 2.00+, the program runs but
  10. ; has no effect.
  11. ;----------------------------------------------------------
  12. ; Declarations:  equates, macros, etc.
  13. ;
  14. TERMINATE    equ    4CH    ;terminate program execution
  15. GETDATE        equ    2AH    ;read DOS' date
  16. GETTIME        equ    2CH    ;read DOS' time
  17. RTC        equ    1AH    ;access real-time clock
  18.   WTIME        equ    03H    ;  write the clock and CMOS
  19.   WDATE        equ    05H    ;  write the date and CMOS
  20. ;------------
  21. DOS    macro    fcn_code
  22.     mov    ah,fcn_code
  23.     int    21H
  24.     endm
  25. ;------------
  26. BIOS    macro    int_no, fcn_code
  27.     mov    ah,fcn_code
  28.     int    int_no
  29.     endm
  30. ;------------
  31. B2BCD    macro    register    ;convert reg to BCD in-place
  32.     mov    al,register    ;get numerand
  33.     call    B2_BCD        ;call routine
  34.     mov    register,al    ;put the result back
  35.     endm
  36. ;----------------------------------------------------------
  37. ; Setup so EXE2BIN can convert program to .COM format
  38. CSEG    segment para public 'CODE'
  39.     assume    cs:CSEG, ds:CSEG
  40. ;
  41.     org    100H
  42. START:    jmp    GO        ;jump around the data area
  43. ;----------------------------------------------------------
  44. BY10    db    10        ;for when we divide by 10
  45. BY100    db    100        ;for when we divide by 100
  46. ;----------------------------------------------------------
  47. MAIN    proc    far        ;cleanliness
  48. GO:    DOS    GETDATE        ;get DOS' date
  49.     mov    ax,cx        ;convert the year into binary
  50.     div    by100        ;...halves.
  51.     xchg    ah,al        ;then, put
  52.     mov    cx,ax        ;...century in ch, year in cl
  53.     B2BCD    ch        ;now convert each byte to BCD
  54.     B2BCD    cl
  55.     B2BCD    dh
  56.     B2BCD    dl
  57.     BIOS    RTC,WDATE    ;and write the date via BIOS
  58.     DOS    GETTIME        ;get DOS' time
  59.     B2BCD    ch        ;convert each byte to BCD
  60.     B2BCD    cl
  61.     B2BCD    dh
  62.     mov    dl,0
  63.     BIOS    RTC,WTIME    ;write the time via BIOS
  64. EXIT:    xor    al,al        ;=0; returns OK for errorlevel
  65.     DOS    TERMINATE    ;goodbye
  66. MAIN    endp
  67. ;----------------------------------------------------------
  68. B2_BCD    proc    near        ;al has binary value
  69.     cbw            ;make it a full word in ax
  70.     div    BY10        ;divide by 10
  71.     shl    al,1        ;put the quotient in the high nibble
  72.     shl    al,1
  73.     shl    al,1
  74.     shl    al,1
  75.     or    al,ah        ;put the two nibbles together in al
  76.     ret
  77. B2_BCD    endp
  78. ;----------------------------------------------------------
  79. CSEG    ends    
  80.     end    START
  81.